package net.oschina.j2cache.cluster;

import net.oschina.j2cache.CacheProviderHolder;
import net.oschina.j2cache.Command;

import java.util.Properties;

/**
 * 实现空的集群通知策略
 *
 * @author Winter Lau(javayou@gmail.com)
 */
public class NoneClusterPolicy implements net.oschina.j2cache.cluster.ClusterPolicy {
  // 命令源标识，随机生成，每个节点都有唯一标识
  private int LOCAL_COMMAND_ID = Command.genRandomSrc();

  @Override
  public void connect(Properties props, CacheProviderHolder holder) {}

  @Override
  public void publish(Command cmd) {}

  @Override
  public void disconnect() {}

  @Override
  public boolean isLocalCommand(Command cmd) {
    return cmd.getSrc() == LOCAL_COMMAND_ID;
  }

  @Override
  public void evict(String region, String... keys) {}

  @Override
  public void clear(String region) {}
}
